package com.coolaid.tictactoe;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.Editable;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainMenu extends Activity {
	
	EditText ipEditText;
	EditText portEditText;
	EditText userName;
	ClientSocket clientSocket;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_menu);
		
		ipEditText = (EditText)findViewById(R.id.ipBox);
		portEditText = (EditText)findViewById(R.id.portBox);
		userName = (EditText)findViewById(R.id.userName);
		
		userName.setText("kingTane");
		ipEditText.setText("192.168.1.100");
		portEditText.setText("4000");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main_menu, menu);
		return true;
	}
	
	public void connect(View view){
		ipEditText.setRawInputType(DEFAULT_KEYS_DIALER);
			
		Editable ipEdit = ipEditText.getText();
		String ip = ipEdit.toString();
		
		Editable portEdit = portEditText.getText();
		int port = Integer.parseInt(portEdit.toString());
		Log.d("TicTacToe", ip + "-" + port);
		
		String userName = this.userName.getText().toString();
		
		Intent showChatMenu = new Intent(this, StringSendReceive.class);
		showChatMenu.putExtra("ip", ip);
		showChatMenu.putExtra("port", port);
		showChatMenu.putExtra("userName", userName);
		startActivity(showChatMenu);
	}

}
